|
RAIS
3.2
|
00001 00028 using System; 00029 using System.Collections.Generic; 00030 using System.IO; 00031 using System.Text; 00032 using System.Web.UI; 00033 using System.Web.UI.WebControls; 00034 using System.Xml; 00035 using System.Linq; 00036 00037 using RAIS.Common.DynamicMaskManagement; 00038 using RAIS.Common.TableManagement; 00039 using RAIS.Common.UserManagement; 00040 00041 using TableTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Table.TableTypeData>; 00042 using TableGroups = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.TableGroup>; 00043 using Tables = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Table>; 00044 using Fields = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Field>; 00045 using FieldTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Field.FieldTypeData>; 00046 using FieldSizes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Field.FieldSizeData>; 00047 using NecessityTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Field.NecessityTypeData>; 00048 using FunctionRoleCategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Category>; 00049 using FunctionRoleSubcategories = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.FunctionRole.Subcategory>; 00050 using Masks = System.Collections.Generic.Dictionary<string, RAIS.Common.UserManagement.Mask>; 00051 using QueryTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Query.QueryTypeData>; 00052 using Queries = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Query>; 00053 using QueryParameterTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.QueryParameter.QueryParameterTypeData>; 00054 //using QueryParameterTypes = System.Collections.Generic.Dictionary<RAIS.Common.TableManagement.QueryParameter.QueryParameterType, RAIS.Common.TableManagement.QueryParameter.QueryParameterTypeData>; 00055 using QueryParameters = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.QueryParameter>; 00056 using CustomizationTypes = System.Collections.Generic.Dictionary<string, RAIS.Common.TableManagement.Query.CustomizationType>; 00057 using DynamicMasks = System.Collections.Generic.Dictionary<string, RAIS.Common.DynamicMaskManagement.DynamicMask>; 00058 00059 namespace RAIS.UI.Common 00060 { 00064 public class TableManagement 00065 { 00066 //********************************************************************* 00067 #region Public static methods 00068 00072 public static void InitializeTableTypeList(DropDownList list) 00073 { 00074 TableTypes supportedTableTypes = RAIS.ApplicationLogicLayer.TableManagement.TableTypes; 00075 00076 string[] tableTypeNames = new string[supportedTableTypes.Count]; 00077 supportedTableTypes.Keys.CopyTo(tableTypeNames, 0); 00078 00079 UI.Common.Controls.InitializeList(list.Items, tableTypeNames); 00080 } 00085 public static void InitializeTableGroupList(DropDownList list) 00086 { 00087 TableGroups supportedTableGroups = RAIS.ApplicationLogicLayer.TableManagement.TableGroups; 00088 00089 string[] tableGroupNames = new string[supportedTableGroups.Count]; 00090 supportedTableGroups.Keys.CopyTo(tableGroupNames, 0); 00091 00092 UI.Common.Controls.InitializeList(list.Items, tableGroupNames); 00093 00094 // Select saved item 00095 bool itemHasBeenFound = false; 00096 if (list.Page.Session[Constants.SAVED_GROUP_TAG] != null) 00097 { 00098 TableGroup tableGroup = ((TableGroup)list.Page.Session[Constants.SAVED_GROUP_TAG]); 00099 if (tableGroup != null) 00100 { 00101 ListItem listItem = list.Items.FindByText(tableGroup.Name); 00102 if (listItem != null) 00103 { 00104 listItem.Selected = true; 00105 itemHasBeenFound = true; 00106 } 00107 } 00108 } 00109 if (!itemHasBeenFound) 00110 { 00111 list.SelectedIndex = 0; 00112 } 00113 } 00118 public static void InitializeTableListWithAllTables(DropDownList list, string selection) 00119 { 00120 Tables supportedTables = RAIS.ApplicationLogicLayer.TableManagement.AllTables; 00121 00122 string[] tableNames = new string[supportedTables.Count]; 00123 supportedTables.Keys.CopyTo(tableNames, 0); 00124 00125 UI.Common.Controls.InitializeList(list.Items, tableNames); 00126 00127 // Selected table could be NULL, so add empty row 00128 list.Items.Insert(0, new ListItem(string.Empty, 0.ToString())); 00129 00130 // Find selection 00131 if (list.SelectedItem != null) 00132 list.SelectedItem.Selected = false; 00133 ListItem listItem = list.Items.FindByText(selection); 00134 if (listItem != null) 00135 { 00136 listItem.Selected = true; 00137 } 00138 else 00139 { 00140 list.SelectedIndex = 0; 00141 } 00142 } 00147 public static void InitializeCategoryList(DropDownList list) 00148 { 00149 FunctionRoleCategories supportedCategories = RAIS.ApplicationLogicLayer.UserManagement.GetAllowCustomizationCategories(); 00150 00151 string[] categoryNames = new string[supportedCategories.Count]; 00152 supportedCategories.Keys.CopyTo(categoryNames, 0); 00153 00154 UI.Common.Controls.InitializeList(list.Items, categoryNames); 00155 } 00160 public static void InitializeSubcategoryListByCategory(DropDownList list, FunctionRole.Category category) 00161 { 00162 InitializeSubcategoryListByCategory(list, category, false, false); 00163 } 00164 00165 public static FunctionRoleSubcategories GetFunctionRoleSubcategoriesByCategory(Page page, FunctionRole.Category category, bool showProtectors, bool showEvaluators, bool reset) 00166 { 00167 string tagName = RAIS.UI.Common.Constants.FUNCTION_ROLE_SUBCATEGORIES_TAG; 00168 FunctionRoleSubcategories functionRolesSubcategories = new Dictionary<string, FunctionRole.Subcategory>(); 00169 00170 if (reset) 00171 page.Session[tagName] = null; 00172 00173 if (page.Session[tagName] == null) 00174 { 00175 functionRolesSubcategories = RAIS.ApplicationLogicLayer.UserManagement.GetFunctionalRoleSubcategories(category, false, showProtectors, showEvaluators); 00176 page.Session[tagName] = functionRolesSubcategories; 00177 } 00178 else 00179 { 00180 functionRolesSubcategories = (FunctionRoleSubcategories)page.Session[tagName]; 00181 } 00182 00183 return functionRolesSubcategories; 00184 } 00189 public static void InitializeSubcategoryListByCategory(DropDownList list, FunctionRole.Category category, bool showProtectors, bool showEvaluators) 00190 { 00191 //FunctionRoleSubcategories supportedSubcategories = RAIS.ApplicationLogicLayer.UserManagement.GetFunctionalRoleSubcategories(category, false, withHidden); 00192 FunctionRoleSubcategories supportedSubcategories = GetFunctionRoleSubcategoriesByCategory(list.Page, category, showProtectors, showEvaluators, true); 00193 00194 string[] subcategoryNames = new string[supportedSubcategories.Count]; 00195 supportedSubcategories.Keys.CopyTo(subcategoryNames, 0); 00196 00197 UI.Common.Controls.InitializeList(list.Items, subcategoryNames); 00198 } 00203 public static void InitializeSubcategoryListBoxByCategory(ListBox list, FunctionRole.Category category) 00204 { 00205 FunctionRoleSubcategories supportedSubcategories = RAIS.ApplicationLogicLayer.UserManagement.GetFunctionalRoleSubcategories(category, false); 00206 00207 list.Page.Session["CurentSubcategories"] = supportedSubcategories.Select(x => x.Value).ToList(); 00208 00209 string[] subcategoryNames = new string[supportedSubcategories.Count]; 00210 supportedSubcategories.Keys.CopyTo(subcategoryNames, 0); 00211 // Subcategories in list must appare in selected by [Order] order 00212 // thats why clear items before Init 00213 list.Items.Clear(); 00214 UI.Common.Controls.InitializeList(list.Items, subcategoryNames); 00215 } 00216 00217 public static Masks GetMasksByCategoryAndSubcategory(Page page, FunctionRole.Category category, FunctionRole.Subcategory subcategory, bool reset) 00218 { 00219 string tagName = RAIS.UI.Common.Constants.MASKS_TAG; 00220 Masks masks = new Dictionary<string, Mask>(); 00221 00222 if (reset) 00223 page.Session[tagName] = null; 00224 00225 if (page.Session[tagName] == null) 00226 { 00227 masks = RAIS.ApplicationLogicLayer.UserManagement.GetMasksWithoutAll(category, subcategory); 00228 page.Session[tagName] = masks; 00229 } 00230 else 00231 { 00232 masks = (Masks)page.Session[tagName]; 00233 } 00234 00235 return masks; 00236 } 00237 00238 public static Masks GetMasksByCategoryAndSubcategoryWithHidden(FunctionRole.Category category, FunctionRole.Subcategory subcategory) 00239 { 00240 return RAIS.ApplicationLogicLayer.UserManagement.GetMasksWithoutAllWhithHidden(category, subcategory); 00241 } 00246 public static void InitializeMaskListByCategoryAndSubcategory(DropDownList list, FunctionRole.Category category, FunctionRole.Subcategory subcategory) 00247 { 00248 Masks supportedMasks = GetMasksByCategoryAndSubcategory(list.Page, category, subcategory, true); 00249 00250 string[] maskNames = new string[supportedMasks.Count]; 00251 supportedMasks.Keys.CopyTo(maskNames, 0); 00252 00253 UI.Common.Controls.InitializeList(list.Items, maskNames); 00254 } 00259 public static void InitializeMaskListByCategorySubcategoryAndType(DropDownList list, FunctionRole.Category category, FunctionRole.Subcategory subcategory, DynamicMask.DynamicMaskTypeData dynamicMaskType) 00260 { 00261 Masks supportedMasks = RAIS.ApplicationLogicLayer.UserManagement.GetMasksWithoutAll(category, subcategory, dynamicMaskType); 00262 00263 string[] maskNames = new string[supportedMasks.Count]; 00264 supportedMasks.Keys.CopyTo(maskNames, 0); 00265 00266 UI.Common.Controls.InitializeList(list.Items, maskNames); 00267 } 00273 public static void InitializeTablesByGroup(Page page, TableGroup tableGroup) 00274 { 00275 InitializeTablesByGroup(page, tableGroup, false, false); 00276 } 00282 public static void InitializeTablesByGroup(Page page, TableGroup tableGroup, bool showProtectors, bool showEvaluators) 00283 //public static void InitializeTablesByGroup(Page page, TableGroup tableGroup, bool desingMode) 00284 { 00285 //Tables tables = RAIS.ApplicationLogicLayer.TableManagement.GetCustomTablesByGroup(tableGroup); 00286 //Tables tables = RAIS.ApplicationLogicLayer.TableManagement.GetTablesByGroup(tableGroup, desingMode); 00287 Tables tables = RAIS.ApplicationLogicLayer.TableManagement.GetTablesByGroup(tableGroup, showProtectors, showEvaluators); 00288 page.Session[RAIS.UI.Common.Constants.TABLES_GROUP_ID_TAG] = tableGroup.ID; 00289 page.Session[RAIS.UI.Common.Constants.TABLES_TAG] = tables; 00290 } 00295 public static void InitializeTableListByGroup(DropDownList list, TableGroup tableGroup) 00296 { 00297 if (list.Page.Session[RAIS.UI.Common.Constants.TABLES_TAG] == null 00298 || list.Page.Session[RAIS.UI.Common.Constants.TABLES_GROUP_ID_TAG] != null 00299 && (int)list.Page.Session[RAIS.UI.Common.Constants.TABLES_GROUP_ID_TAG] != tableGroup.ID) 00300 { 00301 InitializeTablesByGroup(list.Page, tableGroup); 00302 } 00303 00304 Tables tables = (Tables)list.Page.Session[RAIS.UI.Common.Constants.TABLES_TAG]; 00305 00306 string[] tableNames = new string[tables.Count]; 00307 tables.Keys.CopyTo(tableNames, 0); 00308 00309 UI.Common.Controls.InitializeList(list.Items, tableNames); 00310 } 00315 public static void InitializeTableListBoxByGroup(ListBox list, TableGroup tableGroup) 00316 { 00317 InitializeTableListBoxByGroup(list, tableGroup, false, false); 00318 } 00323 public static void InitializeTableListBoxByGroup(ListBox list, TableGroup tableGroup, bool showProtectors, bool showEvaluators) 00324 //public static void InitializeTableListBoxByGroup(ListBox list, TableGroup tableGroup, bool designMode) 00325 { 00326 if (list.Page.Session[RAIS.UI.Common.Constants.TABLES_TAG] == null 00327 || list.Page.Session[RAIS.UI.Common.Constants.TABLES_GROUP_ID_TAG] != null 00328 && (int)list.Page.Session[RAIS.UI.Common.Constants.TABLES_GROUP_ID_TAG] != tableGroup.ID) 00329 { 00330 //InitializeTablesByGroup(list.Page, tableGroup, designMode); 00331 InitializeTablesByGroup(list.Page, tableGroup, showProtectors, showEvaluators); 00332 } 00333 00334 Tables tables = (Tables)list.Page.Session[RAIS.UI.Common.Constants.TABLES_TAG]; 00335 00336 string[] tableNames = new string[tables.Count]; 00337 tables.Keys.CopyTo(tableNames, 0); 00338 00339 // Clear list before initializaton to have tables ordered 00340 list.Items.Clear(); 00341 UI.Common.Controls.InitializeList(list.Items, tableNames); 00342 00343 // Select saved item 00344 bool itemHasBeenFound = false; 00345 if (list.Page.Session[Constants.TABLE_NAME_TAG] != null) 00346 { 00347 ListItem listItem = list.Items.FindByText(list.Page.Session[Constants.TABLE_NAME_TAG].ToString()); 00348 if (listItem != null) 00349 { 00350 listItem.Selected = true; 00351 itemHasBeenFound = true; 00352 } 00353 } 00354 if (!itemHasBeenFound) 00355 { 00356 list.SelectedIndex = 0; 00357 list.Page.Session[Constants.TABLE_NAME_TAG] = list.SelectedValue; 00358 } 00359 } 00365 public static void InitializeTableFieldsList(ListBox list, RAIS.Common.TableManagement.Table table) 00366 { 00367 if (table != null && table.Fields != null) 00368 { 00369 Fields fields = table.Fields;// RAIS.ApplicationLogicLayer.TableManagement.GetFieldsByTable(table); 00370 00371 string[] fieldNames = new string[fields.Count]; 00372 fields.Keys.CopyTo(fieldNames, 0); 00373 // Fields in list must appare in selected by [Order] order 00374 // thats why clear items before Init 00375 list.Items.Clear(); 00376 UI.Common.Controls.InitializeList(list.Items, fieldNames); 00377 } 00378 else 00379 UI.Common.Controls.InitializeList(list.Items, null); 00380 00381 } 00386 public static void InitializeTableFieldCategoryList(DropDownList list) 00387 { 00388 FieldTypes fieldTypes = RAIS.ApplicationLogicLayer.TableManagement.FieldTypes; 00389 00390 string[] fieldTypeNames = new string[fieldTypes.Count]; 00391 fieldTypes.Keys.CopyTo(fieldTypeNames, 0); 00392 00393 UI.Common.Controls.InitializeList(list.Items, fieldTypeNames); 00394 } 00399 public static void InitializeTableFieldSizeListByFieldCategory(DropDownList list, Field.FieldType fieldType) 00400 { 00401 FieldSizes fieldSizes = RAIS.ApplicationLogicLayer.TableManagement.GetFieldSizesByFieldType(fieldType); 00402 00403 string[] fieldSizeNames = new string[fieldSizes.Count]; 00404 fieldSizes.Keys.CopyTo(fieldSizeNames, 0); 00405 00406 UI.Common.Controls.InitializeList(list.Items, fieldSizeNames); 00407 } 00412 public static void InitializeTableFieldNecessityList(DropDownList list) 00413 { 00414 NecessityTypes necessityTypes = RAIS.ApplicationLogicLayer.TableManagement.NecessityTypes; 00415 00416 string[] necessityTypeNames = new string[necessityTypes.Count]; 00417 necessityTypes.Keys.CopyTo(necessityTypeNames, 0); 00418 00419 UI.Common.Controls.InitializeList(list.Items, necessityTypeNames); 00420 } 00425 public static void InitializeRelatedTableList(DropDownList list) 00426 { 00427 Tables supportedRelatedTables = RAIS.ApplicationLogicLayer.TableManagement.AllTables; 00428 00429 string[] tableNames = new string[supportedRelatedTables.Count]; 00430 supportedRelatedTables.Keys.CopyTo(tableNames, 0); 00431 00432 UI.Common.Controls.InitializeList(list.Items, tableNames); 00433 } 00438 public static void InitializeDynamicMaskTypeList(DropDownList list, bool forNewMask) 00439 { 00440 string[] typeNames = new string[2]; 00441 if (forNewMask) 00442 { 00443 typeNames[0] = DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.ListWithFilter].VisibleName; 00444 typeNames[1] = DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.SingleRowMaskWithList].VisibleName; 00445 } 00446 else 00447 { 00448 typeNames[0] = DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.SingleRowMask].VisibleName; 00449 typeNames[1] = DynamicMask.DynamicMaskTypesDictionary[DynamicMask.DynamicMaskType.SingleRowMaskWithList].VisibleName; 00450 } 00451 list.Items.Clear(); 00452 UI.Common.Controls.InitializeList(list.Items, typeNames); 00453 } 00454 00455 public static DynamicMasks GetDynamicMasksByMask(Page page, Mask mask, bool reset) 00456 { 00457 string tagName = RAIS.UI.Common.Constants.DYNAMIC_MASKS_TAG; 00458 DynamicMasks dynamicMasks = new Dictionary<string, DynamicMask>(); 00459 00460 if (reset) 00461 page.Session[tagName] = null; 00462 00463 if (page.Session[tagName] == null) 00464 { 00465 dynamicMasks = RAIS.ApplicationLogicLayer.DynamicMaskManagement.GetDynamicMasksByMask(mask); 00466 page.Session[tagName] = dynamicMasks; 00467 } 00468 else 00469 { 00470 dynamicMasks = (DynamicMasks)page.Session[tagName]; 00471 } 00472 00473 return dynamicMasks; 00474 } 00479 public static void InitializeDynamicMaskListByMaskAndCustomizationType(DropDownList list, Mask mask, Query.CustomizationType customizationType) 00480 { 00481 //DynamicMasks dynamicMasks = RAIS.ApplicationLogicLayer.DynamicMaskManagement.GetDynamicMasksByMask(mask); 00482 DynamicMasks dynamicMasks = GetDynamicMasksByMask(list.Page, mask, true); 00483 DynamicMasks filteredDynamicMasks = FilterDynamicMasksByCustomizationType(dynamicMasks, customizationType); 00484 00485 string[] dynamicMaskNames = new string[filteredDynamicMasks.Count]; 00486 filteredDynamicMasks.Keys.CopyTo(dynamicMaskNames, 0); 00487 00488 UI.Common.Controls.InitializeList(list.Items, dynamicMaskNames); 00489 } 00490 00491 public static Queries GetQueries(Page page, bool reset) 00492 { 00493 string tagName = RAIS.UI.Common.Constants.QUERIES_TAG; 00494 Queries queries = new Dictionary<string, Query>(); 00495 00496 if (reset) 00497 page.Session[tagName] = null; 00498 00499 if (page.Session[tagName] == null) 00500 { 00501 queries = RAIS.ApplicationLogicLayer.TableManagement.GetQueries(); 00502 page.Session[tagName] = queries; 00503 } 00504 else 00505 { 00506 queries = (Queries)page.Session[tagName]; 00507 } 00508 00509 return queries; 00510 } 00511 00512 public static QueryParameters GetQueryParametersByQuery(Page page, Query query, bool reset) 00513 { 00514 string tagName = RAIS.UI.Common.Constants.QUERY_PARAMETERS_TAG; 00515 QueryParameters queryParameters = new Dictionary<string, QueryParameter>(); 00516 00517 if (reset) 00518 page.Session[tagName] = null; 00519 00520 if (query != null) 00521 { 00522 if (page.Session[tagName] == null) 00523 { 00524 queryParameters = RAIS.ApplicationLogicLayer.TableManagement.GetQueryParametersByQuery(query); 00525 page.Session[tagName] = queryParameters; 00526 } 00527 else 00528 { 00529 queryParameters = (QueryParameters)page.Session[tagName]; 00530 } 00531 } 00532 return queryParameters; 00533 } 00534 00535 public static QueryParameterTypes GetQueryParameterTypesByQuery(Page page, Query query, bool reset) 00536 { 00537 string tagName = RAIS.UI.Common.Constants.QUERY_PARAMETER_TYPES_TAG; 00538 QueryParameterTypes queryParameterTypes = new Dictionary<string,QueryParameter.QueryParameterTypeData>(); 00539 00540 if (reset) 00541 page.Session[tagName] = null; 00542 00543 if (query != null) 00544 { 00545 if (page.Session[tagName] == null) 00546 { 00547 queryParameterTypes = RAIS.ApplicationLogicLayer.TableManagement.GetQueryParameterTypesByQuery(query); 00548 page.Session[tagName] = queryParameterTypes; 00549 } 00550 else 00551 { 00552 queryParameterTypes = (QueryParameterTypes)page.Session[tagName]; 00553 } 00554 } 00555 return queryParameterTypes; 00556 } 00557 00562 public static void InitializeCustomQueryListBox(ListBox list, string selection) 00563 { 00564 Queries supportedqueries = GetQueries(list.Page, true); 00565 00566 string[] queryNames = new string[supportedqueries.Count]; 00567 supportedqueries.Keys.CopyTo(queryNames, 0); 00568 00569 // Clear list before initializaton to have queries ordered 00570 list.Items.Clear(); 00571 UI.Common.Controls.InitializeList(list.Items, queryNames); 00572 00573 // Select current value 00574 if (list.SelectedItem != null) 00575 list.SelectedItem.Selected = false; 00576 ListItem listItem = list.Items.FindByText(selection); 00577 if (listItem != null) 00578 listItem.Selected = true; 00579 else 00580 list.SelectedIndex = 0; 00581 } 00586 public static void InitializeCustomQueryListByQueryType(DropDownList list, Query.QueryType queryType, string selection) 00587 { 00588 Queries supportedqueries = ApplicationLogicLayer.TableManagement.GetQueriesByQueryType(queryType); 00589 00590 string[] queryNames = new string[supportedqueries.Count]; 00591 supportedqueries.Keys.CopyTo(queryNames, 0); 00592 00593 // Clear list before initializaton to have queries ordered 00594 list.Items.Clear(); 00595 UI.Common.Controls.InitializeList(list.Items, queryNames); 00596 00597 // Selected query could be NULL, so add empty row 00598 list.Items.Insert(0, new ListItem(string.Empty, 0.ToString())); 00599 00600 // Select current value 00601 if (list.SelectedItem != null) 00602 list.SelectedItem.Selected = false; 00603 ListItem listItem = list.Items.FindByText(selection); 00604 if (listItem != null) 00605 listItem.Selected = true; 00606 else 00607 list.SelectedIndex = 0; 00608 } 00613 public static void InitializeCustomQueryListByCustomizationType(DropDownList list, Query.CustomizationType customizationType, string selection) 00614 { 00615 Queries supportedqueries = ApplicationLogicLayer.TableManagement.GetQueriesByCustomizationType(customizationType); 00616 00617 string[] queryNames = new string[supportedqueries.Count]; 00618 supportedqueries.Keys.CopyTo(queryNames, 0); 00619 00620 // Clear list before initializaton to have queries ordered 00621 list.Items.Clear(); 00622 UI.Common.Controls.InitializeList(list.Items, queryNames); 00623 00624 // Selected query could be NULL, so add empty row 00625 list.Items.Insert(0, new ListItem(string.Empty, 0.ToString())); 00626 00627 // Select current value 00628 if (list.SelectedItem != null) 00629 list.SelectedItem.Selected = false; 00630 ListItem listItem = list.Items.FindByText(selection); 00631 if (listItem != null) 00632 listItem.Selected = true; 00633 else 00634 list.SelectedIndex = 0; 00635 } 00640 public static void InitializeCustomQueryParametersListBoxByQuery(ListBox list, Query query, string selection) 00641 { 00642 QueryParameters queryParameters = GetQueryParametersByQuery(list.Page, query, true); 00643 00644 string[] queryParameterNames = new string[queryParameters.Count]; 00645 queryParameters.Keys.CopyTo(queryParameterNames, 0); 00646 00647 // Clear list before initializaton to have queries ordered 00648 list.Items.Clear(); 00649 UI.Common.Controls.InitializeList(list.Items, queryParameterNames); 00650 00651 // Select current value 00652 if (list.SelectedItem != null) 00653 list.SelectedItem.Selected = false; 00654 ListItem listItem = list.Items.FindByText(selection); 00655 if (listItem != null) 00656 listItem.Selected = true; 00657 else 00658 list.SelectedIndex = 0; 00659 } 00664 public static void InitializeQueryTypeList(DropDownList list) 00665 { 00666 QueryTypes queryTypes = RAIS.ApplicationLogicLayer.TableManagement.QueryTypes; 00667 00668 string[] queryTypeNames = new string[queryTypes.Count]; 00669 queryTypes.Keys.CopyTo(queryTypeNames, 0); 00670 00671 UI.Common.Controls.InitializeList(list.Items, queryTypeNames); 00672 } 00677 public static void InitializeQueryParameterTypeList(DropDownList list, Query query, string selection) 00678 { 00679 QueryParameterTypes queryParameterTypes = GetQueryParameterTypesByQuery(list.Page, query, true); 00680 00681 string[] queryParameterTypeNames = new string[queryParameterTypes.Count]; 00682 queryParameterTypes.Keys.CopyTo(queryParameterTypeNames, 0); 00683 00684 UI.Common.Controls.InitializeList(list.Items, queryParameterTypeNames); 00685 00686 // Select current value 00687 if (list.SelectedItem != null) 00688 list.SelectedItem.Selected = false; 00689 ListItem listItem = list.Items.FindByText(selection); 00690 if (listItem != null) 00691 listItem.Selected = true; 00692 else 00693 list.SelectedIndex = 0; 00694 } 00699 public static void InitializeCustomizationTypeList(DropDownList list, string selection) 00700 { 00701 CustomizationTypes types = RAIS.ApplicationLogicLayer.TableManagement.GetCustomizationTypes(); 00702 00703 string[] customizationTypeNames = new string[types.Count]; 00704 types.Keys.CopyTo(customizationTypeNames, 0); 00705 00706 UI.Common.Controls.InitializeList(list.Items, customizationTypeNames); 00707 00708 // Select current value 00709 if (list.SelectedItem != null) 00710 list.SelectedItem.Selected = false; 00711 ListItem listItem = list.Items.FindByText(selection); 00712 if (listItem != null) 00713 listItem.Selected = true; 00714 else 00715 list.SelectedIndex = 0; 00716 } 00717 00718 public static FunctionRoleCategories GetFunctionRoleCategories(Page page, bool reset) 00719 { 00720 string tagName = RAIS.UI.Common.Constants.FUNCTION_ROLE_CATEGORIES_TAG; 00721 FunctionRoleCategories functionRolesCategories = new Dictionary<string,FunctionRole.Category>(); 00722 00723 if (reset) 00724 page.Session[tagName] = null; 00725 00726 if (page.Session[tagName] == null) 00727 { 00728 functionRolesCategories = RAIS.ApplicationLogicLayer.UserManagement.FunctionalRoleCategories; 00729 page.Session[tagName] = functionRolesCategories; 00730 } 00731 else 00732 { 00733 functionRolesCategories = (FunctionRoleCategories)page.Session[tagName]; 00734 } 00735 00736 return functionRolesCategories; 00737 } 00742 public static void InitializeCategoriesListByCustomizationType(DropDownList list, Query.CustomizationType customizationType) 00743 { 00744 //FunctionRoleCategories functionRolesCategories = RAIS.ApplicationLogicLayer.UserManagement.FunctionalRoleCategories; 00745 FunctionRoleCategories functionRolesCategories = GetFunctionRoleCategories(list.Page, true); 00746 FunctionRoleCategories filtredCategories = FilterCategoriesByCustomizationType(functionRolesCategories, customizationType); 00747 00748 list.Page.Session[RAIS.UI.Common.Constants.FUNCTION_ROLE_CATEGORIES_TAG] = filtredCategories; 00749 00750 string[] functionRoleCategoriesNames = new string[filtredCategories.Keys.Count]; 00751 filtredCategories.Keys.CopyTo(functionRoleCategoriesNames, 0); 00752 00753 UI.Common.Controls.InitializeList(list.Items, functionRoleCategoriesNames); 00754 } 00763 private static FunctionRoleCategories FilterCategoriesByCustomizationType(FunctionRoleCategories categories, Query.CustomizationType customizationType) 00764 { 00765 FunctionRoleCategories fitredCategories = new FunctionRoleCategories(); 00766 switch (customizationType) 00767 { 00768 case Query.CustomizationType.ConsistencyCheck: 00769 case Query.CustomizationType.EntryFilter: 00770 case Query.CustomizationType.ListWithFilter: 00771 case Query.CustomizationType.RanAutogeneration: 00772 fitredCategories[RAIS.Common.Constants.CATEGORY_NAME_REGULATORY_SYSTEM] = categories[RAIS.Common.Constants.CATEGORY_NAME_REGULATORY_SYSTEM]; 00773 fitredCategories[RAIS.Common.Constants.CATEGORY_NAME_INPUT] = categories[RAIS.Common.Constants.CATEGORY_NAME_INPUT]; 00774 break; 00775 case Query.CustomizationType.QueryReport: 00776 fitredCategories[RAIS.Common.Constants.CATEGORY_NAME_QUERY] = categories[RAIS.Common.Constants.CATEGORY_NAME_QUERY]; 00777 break; 00778 case Query.CustomizationType.StatisticsReport: 00779 fitredCategories[RAIS.Common.Constants.CATEGORY_NAME_STATISTICS] = categories[RAIS.Common.Constants.CATEGORY_NAME_STATISTICS]; 00780 break; 00781 } 00782 return fitredCategories; 00783 } 00792 private static DynamicMasks FilterDynamicMasksByCustomizationType(DynamicMasks dynamicMasks, Query.CustomizationType customizationType) 00793 { 00794 DynamicMasks filteredDynamicMasks = new Dictionary<string,DynamicMask>(); 00795 00796 if (customizationType == Query.CustomizationType.ListWithFilter) 00797 { 00798 foreach (KeyValuePair<string, DynamicMask> kvp in dynamicMasks) 00799 if (kvp.Value.Type == DynamicMask.DynamicMaskType.ListWithFilter) 00800 filteredDynamicMasks.Add(kvp.Key, kvp.Value); 00801 } 00802 else if (customizationType == Query.CustomizationType.ConsistencyCheck 00803 || customizationType == Query.CustomizationType.EntryFilter 00804 || customizationType == Query.CustomizationType.RanAutogeneration 00805 ) 00806 { 00807 foreach (KeyValuePair<string, DynamicMask> kvp in dynamicMasks) 00808 if (kvp.Value.Type != DynamicMask.DynamicMaskType.ListWithFilter 00809 && kvp.Value.Type != DynamicMask.DynamicMaskType.ReportMask 00810 ) 00811 filteredDynamicMasks.Add(kvp.Key, kvp.Value); 00812 } 00813 else 00814 { 00815 filteredDynamicMasks = dynamicMasks; 00816 } 00817 00818 return filteredDynamicMasks; 00819 } 00824 public static void SetDynamicMaskTypeListCurrentSelection(DropDownList list, string selectedMaskType) 00825 { 00826 ListItem listItem = list.Items.FindByText(selectedMaskType); 00827 if (listItem != null) 00828 { 00829 list.SelectedItem.Selected = false; 00830 listItem.Selected = true; 00831 } 00832 } 00833 00834 public static bool SaveTablesScript(ref string returnMessage) 00835 { 00836 00837 try 00838 { 00839 XmlDocument xmlDoc = RAIS.ApplicationLogicLayer.TableManagement.GetTableAndFieldXml(); 00840 string scriptStart = 00841 "SET NOCOUNT ON\n" 00842 + "GO\n" 00843 + "\n" 00844 + "DELETE FROM [RAIS Field]\n" 00845 + "GO\n" 00846 + "DELETE FROM [RAIS Table]\n" 00847 + "GO\n" 00848 + "\n" 00849 + "SET QUOTED_IDENTIFIER ON\n" 00850 + "GO\n" 00851 + "\n" 00852 + "DECLARE @tableStr nvarchar(max), @tableXml xml\n" 00853 + "SET @tableStr = \n" 00854 + "'"; 00855 string scriptEnd = "'\n" 00856 + "\n" 00857 + "SELECT @tableXml = CAST(CAST(@tableStr AS varchar(max)) AS XML)\n" 00858 + "\n" 00859 + "EXEC asp_LoadTableAndFieldFromXml @tableXml, 1\n"; 00860 00861 using (StreamWriter outFile = new StreamWriter("c:\\FillTableAndFieldFromXml.sql")) 00862 { 00863 outFile.Write(scriptStart); 00864 xmlDoc.Save(outFile); 00865 outFile.Write(scriptEnd); 00866 } 00867 00868 returnMessage = RAIS.Common.Messages.SCRIPT_SAVED; 00869 return true; 00870 } 00871 catch (Exception ex) 00872 { 00873 returnMessage = ex.Message; 00874 return false; 00875 } 00876 } 00877 00878 public static Fields GetFieldsByDynamicMask(Page page, DynamicMask dynamicMask, Query.CustomizationType customizationType, bool reset) 00879 { 00880 string tagName = RAIS.UI.Common.Constants.FIELDS_TAG; 00881 Fields fields = new Dictionary<string, Field>(); 00882 00883 if (reset) 00884 page.Session[tagName] = null; 00885 00886 if (page.Session[tagName] == null) 00887 { 00888 if (customizationType == Query.CustomizationType.EntryFilter) 00889 fields = RAIS.ApplicationLogicLayer.TableManagement.GetLookupFieldsByTable(dynamicMask.Table); 00890 else 00891 fields = RAIS.ApplicationLogicLayer.TableManagement.GetTextFieldsByTable(dynamicMask.Table); 00892 //fields = RAIS.ApplicationLogicLayer.TableManagement.GetFieldsByTable(dynamicMask.Table); 00893 page.Session[tagName] = fields; 00894 } 00895 else 00896 { 00897 fields = (Fields)page.Session[tagName]; 00898 } 00899 00900 return fields; 00901 } 00902 00903 public static void InitializeFieldListByDynamicMaskAndCustomizationType(DropDownList list, DynamicMask dynamicMask, Query.CustomizationType customizationType) 00904 { 00905 Fields fields = GetFieldsByDynamicMask(list.Page, dynamicMask, customizationType, true); 00906 00907 string[] fieldsNames = new string[fields.Keys.Count]; 00908 fields.Keys.CopyTo(fieldsNames, 0); 00909 00910 UI.Common.Controls.InitializeList(list.Items, fieldsNames); 00911 } 00912 00913 public static bool CheckQueryAssignedObjects(Query query, ref string returnMessage) 00914 { 00915 bool success = true; 00916 List<string> assignedObjectsNames = 00917 ApplicationLogicLayer.TableManagement.GetQueryAssignedObjectsNames(query); 00918 00919 if (assignedObjectsNames.Count != 0) 00920 { 00921 string objectsStr = (assignedObjectsNames.Count == 1) ? "object" : "objects"; 00922 string objectType = string.Empty; 00923 switch (query.Type) 00924 { 00925 case RAIS.Common.TableManagement.Query.QueryType.ConsistencyCheck: 00926 case RAIS.Common.TableManagement.Query.QueryType.PreselectionList: 00927 case RAIS.Common.TableManagement.Query.QueryType.Query: 00928 case RAIS.Common.TableManagement.Query.QueryType.Statistics: 00929 objectType = "dynamic mask"; 00930 break; 00931 case RAIS.Common.TableManagement.Query.QueryType.EntryFilter: 00932 case RAIS.Common.TableManagement.Query.QueryType.RanAutogeneration: 00933 objectType = "field"; 00934 break; 00935 case RAIS.Common.TableManagement.Query.QueryType.PreselectionFilter: 00936 objectType = "preselection filter"; 00937 break; 00938 case RAIS.Common.TableManagement.Query.QueryType.DataRoleRestriction: 00939 objectType = "(Data Role Restriction)"; 00940 break; 00941 } 00942 StringBuilder message = new StringBuilder(); 00943 message.Append(string.Format("The query is assigned to the {0}: ", objectsStr)); 00944 bool firstObject = true; 00945 foreach (string objectName in assignedObjectsNames) 00946 { 00947 message.Append(string.Format("{0}{1} {2}" 00948 , (firstObject) ? string.Empty : " ," 00949 , objectName 00950 , objectType)); 00951 firstObject = false; 00952 } 00953 message.Append(string.Format(". Unassign the query from the {0} and then retry the operation.", objectsStr)); 00954 00955 returnMessage = message.ToString(); 00956 success = false; 00957 } 00958 00959 return success; 00960 } 00961 #endregion 00962 } 00963 }